package com.thinksns.sociax.t4.model;


import com.thinksns.sociax.thinksnsbase.bean.SociaxItem;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author LeiYan
 * @describe 认证分组
 * @date 2017/7/21
 * @contact email:907238552@qq.com
 */

public class VerifyDetails extends SociaxItem{
    /*show接口返回*/
    private int id;
    private int verified; // -1:未认证，0：审核中，1：已认证，2：被驳回
    // usergroup
    private int usergroup_id; // 5:个人认证 6：机构认证；其他;;show接口中与 id 同级，详情中在 usergroup 中,字段为 user_group_id
    private String user_group_name;
    private String user_group_icon;
    private int is_authenticate;
  // 其他信息
    private String company; // 机构名称【机构认证时需要】
    private String realname; // 负责人姓名/真实姓名
    private String idcard; // 身份证号码
    private String phone; // 联系方式
    private String info; // 认证资料
    private List<ModelAttach> attach_id = new ArrayList<>(); // 认证附件
    private String reason; // 认证补充
    private VerifyModel user_verified_category; //认证分类 项

    public VerifyDetails(){}

    @Override
    public boolean checkValid() {
        return false;
    }

    @Override
    public String getUserface() {
        return null;
    }

    public VerifyDetails(JSONObject object){
      if (object == null) return;
        if (object.has("id")){
            setId(object.optInt("id"));
        }
        if (object.has("verified")){
            setVerified(object.optInt("verified"));
        }
        if (object.has("usergroup_id")){
            setUsergroup_id(object.optInt("usergroup_id"));
        }
        if (object.has("usergroup") && !object.isNull("usergroup")){
            JSONObject userGroup = object.optJSONObject("usergroup");
            if (userGroup.has("user_group_id")){
                setUsergroup_id(userGroup.optInt("user_group_id"));
            }
            if (userGroup.has("user_group_name")){
                setUser_group_name(userGroup.optString("user_group_name"));
            }
            if (userGroup.has("user_group_icon")){
                setUser_group_icon(userGroup.optString("user_group_icon"));
            }
            if (userGroup.has("is_authenticate")){
                setIs_authenticate(userGroup.optInt("is_authenticate"));
            }
        }
        if (object.has("company")){
            setCompany(object.optString("company"));
        }
        if (object.has("realname")){
            setRealname(object.optString("realname"));
        }
        if (object.has("idcard")){
            setIdcard(object.optString("idcard"));
        }
        if (object.has("phone")){
            setPhone(object.optString("phone"));
        }
        if (object.has("info")){
            setInfo(object.optString("info"));
        }
        if (object.has("attach_id") && !object.isNull("attach_id")){
            JSONArray array = object.optJSONArray("attach_id");
            ModelAttach attach =  null;
            for (int i = 0; i < array.length(); i++){
                attach = new ModelAttach(array.optJSONObject(i));
                attach_id.add(attach);
            }
        }
        if (object.has("reason")){
            setReason(object.optString("reason"));
        }
        if (object.has("user_verified_category") && !object.isNull("user_verified_category")){
            JSONObject category = object.optJSONObject("user_verified_category");
            user_verified_category = new VerifyModel(category);
            if (category.has("user_verified_category_id")){
                user_verified_category.setVerify_id(category.optString("user_verified_category_id"));
            }
        }
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getVerified() {
        return verified;
    }

    public void setVerified(int verified) {
        this.verified = verified;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public List<ModelAttach> getAttach_id() {
        return attach_id;
    }

    public void setAttach_id(List<ModelAttach> attach_id) {
        this.attach_id = attach_id;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public VerifyModel getUser_verified_category() {
        return user_verified_category;
    }

    public void setUser_verified_category(VerifyModel user_verified_category) {
        this.user_verified_category = user_verified_category;
    }

    public int getUsergroup_id() {
        return usergroup_id;
    }

    public void setUsergroup_id(int usergroup_id) {
        this.usergroup_id = usergroup_id;
    }

    public String getUser_group_name() {
        return user_group_name;
    }

    public void setUser_group_name(String user_group_name) {
        this.user_group_name = user_group_name;
    }

    public String getUser_group_icon() {
        return user_group_icon;
    }

    public void setUser_group_icon(String user_group_icon) {
        this.user_group_icon = user_group_icon;
    }

    public int getIs_authenticate() {
        return is_authenticate;
    }

    public void setIs_authenticate(int is_authenticate) {
        this.is_authenticate = is_authenticate;
    }
}
